package com.joshua.spring.jobs;

import com.joshua.spring.entity.vo.GlobalResponse;
import com.joshua.spring.spi.FtConsumerClient;
import com.joshua.spring.util.KeyUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import static com.joshua.spring.constants.LogInfoConstants.TRACE_ID;

/**
 * projectName dragon-cloud
 * package com.joshua.spring.jobs
 * classname  RemoteCallJob
 * <p>
 * description 远程调用job
 * </p>
 *
 * @author <a href="mailto:joshualwork@163.com">joshua_liu</a>
 * @date 2020/9/14 8:42
 */
@Slf4j
public class RemoteCallJob extends QuartzJobBean {
    @Autowired
    private FtConsumerClient consumerClient;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        MDC.put(TRACE_ID, KeyUtils.getKeyWithDate("job"));
        log.info("Remote job start...");
        GlobalResponse result = consumerClient.pathInfo();
        log.info("Remote job response data{}", result);
        log.info("Remote job stop...");
        MDC.remove(TRACE_ID);
    }
}
